package com.cleaningcloud.cld.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldWelfare;
import com.cleaningcloud.cld.service.ICldWelfareService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 福利津贴Controller
 * 
 * @author cleaningcloud
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/welfare")
public class CldWelfareController extends BaseController
{
    @Autowired
    private ICldWelfareService cldWelfareService;

    /**
     * 查询福利津贴列表
     */
    @RequiresPermissions("cld:welfare:list")
    @GetMapping("/list")
    public TableDataInfo list(CldWelfare cldWelfare)
    {
        startPage();
        List<CldWelfare> list = cldWelfareService.selectCldWelfareList(cldWelfare);
        return getDataTable(list);
    }


    /**
     * 查询福利津贴列表
     */
    @GetMapping("/getList")
    public AjaxResult getList(CldWelfare cldWelfare)
    {
        List<CldWelfare> list = cldWelfareService.selectCldWelfareList(cldWelfare);
        return success(list);
    }


    /**
     * 获取福利津贴详细信息
     */
    @RequiresPermissions("cld:welfare:query")
    @GetMapping(value = "/{walfareId}")
    public AjaxResult getInfo(@PathVariable("walfareId") Long walfareId)
    {
        return success(cldWelfareService.selectCldWelfareByWalfareId(walfareId));
    }

    /**
     * 新增福利津贴
     */
    @RequiresPermissions("cld:welfare:add")
    @Log(title = "福利津贴", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldWelfare cldWelfare)
    {
        return toAjax(cldWelfareService.insertCldWelfare(cldWelfare));
    }

    /**
     * 修改福利津贴
     */
    @RequiresPermissions("cld:welfare:edit")
    @Log(title = "福利津贴", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldWelfare cldWelfare)
    {
        return toAjax(cldWelfareService.updateCldWelfare(cldWelfare));
    }

    /**
     * 删除福利津贴
     */
    @RequiresPermissions("cld:welfare:remove")
    @Log(title = "福利津贴", businessType = BusinessType.DELETE)
	@DeleteMapping("/{walfareIds}")
    public AjaxResult remove(@PathVariable Long[] walfareIds)
    {
        return toAjax(cldWelfareService.deleteCldWelfareByWalfareIds(walfareIds));
    }
}
